home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Supervisor's Toolkit
/
Network Supervisor's Toolkit.iso
/
tools
/
lu62
/
novell
/
curhscb.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-10
|
4KB
|
118 lines
#include <include.h>
#include <string.h>
#include <malloc.h>
#include <stdlib.h>
#include <stdio.h>
extern void *hscb_lst_ptr;
extern void *nau_lst_ptr;
extern int totalNau;
unsigned long findnau (void *np, void **naupp);
struct hscb *fndhsad(char *);
/*********************CRHSCB********************************************/
struct hscb *crhscb( char *mylu,char *partlu )
{
unsigned long rc;
struct hscb *whscb,*whscbq;
struct nau *wnau;
whscb = calloc (1,sizeof(struct hscb));
if (whscb == NULL )
return (NULL);
rc = findnau ( mylu ,&wnau);
if (rc != 0)
return (NULL);
whscb->naup = wnau;
memcpy (whscb->hslunam, partlu, 8);
wnau -> link = whscb;
whscb -> cor = whscb;
rc = findnau ( partlu,&wnau);
if (rc != 0)
return (NULL);
memcpy( whscb -> part_net_ad, wnau -> net_ad, 6);
if (hscb_lst_ptr == NULL )
hscb_lst_ptr = whscb;
else
{
whscbq = hscb_lst_ptr;
while (whscbq -> next != NULL )
whscbq = whscbq -> next;
whscbq -> next = whscb;
}
return (whscb);
}
/*************************FINDHSCB********************************/
struct hscb *findhscb(char *ccor )
{
struct hscb *whscb;
whscb = hscb_lst_ptr;
if (whscb -> cor == ccor)
return(whscb);
whscb = whscb -> next;
do {
if (whscb ->cor == ccor)
return (whscb);
whscb = whscb -> next;
} while (whscb != NULL );
return (NULL);
}
/*************************FNDHSAD********************************/
struct hscb *fndhsad( char *p_ad )
{
struct hscb *whscb;
whscb = hscb_lst_ptr;
while ( whscb != NULL ){
if( (memcmp (whscb -> part_net_ad,p_ad,6)) == 0)
break;
whscb = whscb -> next;
}
return (whscb);
}
/**************************DELHSCB************************************/
int delhscb (struct hscb *whscb)
{
struct hscb *whscbq;
whscbq = hscb_lst_ptr;
if (whscbq == whscb)
hscb_lst_ptr = NULL;
do {
if ( whscbq -> next == whscb)
{
whscbq -> next = whscb -> next;
free(whscb);
return 0;
}
whscbq = whscbq -> next;
} while ( whscbq != NULL );
return 0;
}
/****************************FINDNAU***********************************/
unsigned long findnau (char *np,struct nau **naupp)
{
struct nau *naup;
int i;
naup = nau_lst_ptr;
i = 0;
do {
if (memcmp( np, naup -> name,8) == 0)
{
*naupp = naup;
return 0;
}
naup ++;
i++;
} while ( i <= totalNau );
return (i);
}
/******************************THE END *******************************/